package program01;

/**
 * @version 1.0
 * @since:
 * @ClassName:Array
 * @author: Li Jiahui
 * @date: 2021-01-02 18:17
 */
public class Array {
    //1.自定义成员变量
    static int[][] dyadicArray = new int[16][16];
    //2.自定义成员方法
    void computer(){
        System.out.println("先随机产生一个二维数组的值，在打印出来：");
        for (int i = 0; i < 16; i++)
        {
            for (int j = 0; j < 16; j++)
            {
                dyadicArray[i][j] = (int)(Math.random()*100)+1;//范围为：1-100
                System.out.print("[" + i + "][" + j + "]=" + dyadicArray[i][j] + "\t");//t是用来格式化输出
            }
            System.out.println(" ");
        }
    }
    void  show(){

        for (int i = 0; i < 16; i++) {
            int sumRows = 0;
            int sumColumns = 0;
            for (int j = 0; j < 16; j++) {
                sumRows += dyadicArray[i][j];
                sumColumns += dyadicArray[j][i];
            }
            System.out.print("打印第" + (i+1) +"行的累加和：" + sumRows + "\t");
            System.out.println("打印第" + (i+1) +"列的累加和：" + sumColumns + "\t");
        }
    }
}

